using System.ComponentModel.DataAnnotations;
using FytSoa.Common.Enum;
using FytSoa.Domain.Crm;
using FytSoa.Domain.Hr;
using SqlSugar;

namespace FytSoa.Domain.Erp;

/// <summary>
/// erp-销售表
/// </summary>
[SugarTable("erp_sales_order")]
public class ErpSalesOrder:Entity
{
    /// <summary>
    /// 订单编号
    /// </summary>
    [Required]
    [StringLength(50)]
    public string Number { get; set; }

    /// <summary>
    /// 客户ID
    /// </summary>
    [Required]
    public long CustomerId { get; set; }
    
    /// <summary>
    /// 客户信息
    /// </summary>
    [Navigate(NavigateType.OneToOne, nameof(CustomerId))]
    public CrmCustomer Customer { get; set; }

    /// <summary>
    /// 负责人
    /// </summary>
    [Required]
    public long UserId { get; set; }
    
    /// <summary>
    /// 负责人
    /// </summary>
    [Navigate(NavigateType.OneToOne, nameof(UserId))]
    public HrEmployee Employee { get; set; }

    /// <summary>
    /// 下单时间
    /// </summary>
    public DateTime? OrderDate { get; set; }

    /// <summary>
    /// 订单总额
    /// </summary>
    [Required]
    public decimal TotalAmount { get; set; }

    /// <summary>
    /// 已收金额
    /// </summary>
    public decimal PaidAmount { get; set; }

    /// <summary>
    /// 草稿','已审核','部分发货','已完成','已关闭
    /// </summary>
    public ErpSalesOrderStatusEnum OrderStatus { get; set; } = ErpSalesOrderStatusEnum.UnAudited;

    /// <summary>
    /// 是否开票
    /// </summary>
    public bool InvoiceStatus { get; set; } = true;

    /// <summary>
    /// 创建人
    /// </summary>
    public string CreateUser { get; set; }

    /// <summary>
    /// 创建时间
    /// </summary>
    [Required]
    public DateTime CreateTime { get; set; } = DateTime.Now;

    /// <summary>
    /// 更新人
    /// </summary>
    public string UpdateUser { get; set; }

    /// <summary>
    /// 更新时间
    /// </summary>
    public DateTime? UpdateTime { get; set; }


}